#include "plane.h"
#include <stdio.h>
#include <GL/glut.h>

using namespace std;

Plane::Plane(float d, float *m)
{
    if (m)
    {
	for (int i = 0; i < 4 * 4; ++i)
	{
	    _m[i] = m[i];
	}
    }
    else
    {
	for (int i = 0; i < 4 * 4; ++i)
	{
	    _m[i] = 0.0;
	}
    }
    _m[0] = 1.0;
    _m[5] = 1.0;
    _m[10] = 1.0;
    _m[15] = 1.0;

    size = 5;
}

void Plane::renderInLocalFrame() const
{
    float x1[3] = {_m[12] + size, _m[13] + size, _m[14]};
    float x3[3] = {_m[12] + size, _m[13] - size, _m[14]};
    float x4[3] = {_m[12] - size, _m[13] - size, _m[14]};
    float x2[3] = {_m[12] - size, _m[13] + size, _m[14]};

    printf("asdfklhasdlkjfhaklsjdhfkjashdfkjhaskdfh");

    glBegin(GL_QUADS);
    //glTranslatef(x1[0], x1[0], x1[2]);
    glVertex3fv(x1);
    glVertex3fv(x2);
    glVertex3fv(x3);
    glVertex3fv(x4);

    glEnd();
}
